public class SoundEffects extends Thread {

	Minim minim;
        AudioPlayer player;
        AudioSample sampler;
	int option;
	public void run(){
          if(option == 0) {
            player.loop();
          } else {
            sampler.trigger(); 
          }
	}

        void updateSoundFile(String fileName){
         player = minim.loadFile(fileName); 
        }
        
        void setGain(float gain){
         player.setGain(gain); 
        }
        
        void play(){
         player.play(1); 
        }

        void cleanUp()
        {
          if(option == 0) {
            player.close();
          } else {
            sampler.close(); 
          }
          minim.stop();
          super.stop();
        }
	
	public SoundEffects(PApplet p, String fileName, int option){
          minim = new Minim(p);
          if(option == 0) {
            player = minim.loadFile(fileName);
          } else {
            sampler = minim.loadSample(fileName); 
          }
          this.option = option;
	}
	
}
